Skip to content

Conversation

mawelborn
Copy link
Contributor

@mawelborn mawelborn commented Jan 29, 2025

Summary

This PR implements configurable, best-practices retry behavior for both IndicoClient and AsyncIndicoClient with consistent socket connect and read timeouts. This replaces the existing retry behavior that's only present on the async client and isn't configurable. IndicoConfig has new options to control retry behavior, with reasonable defaults:

IndicoConfig(
    retry_count: int = 4,  # Retry API calls this many times.
    retry_wait: float = 1,  # Wait this many seconds after the first error before retrying.
    retry_backoff: float = 4,  # Multiply the wait time by this amount for each additional error.
    retry_jitter: float = 1,  # Add a random amount of time (up to this percent as a decimal) to the wait time to prevent simultaneous retries.
)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • Jira story/task is put into PR title
  • Code has been self-reviewed
  • Hard-to-understand areas have been commented
  • Documentation has been updated
  • My changes generate no new warnings
  • Unit tests have been added for base functionality and known edge cases
  • Any dependent changes have been merged and published in downstream modules

@mawelborn mawelborn added the enhancement New feature or request label Jan 29, 2025
@mawelborn mawelborn self-assigned this Jan 29, 2025
@mawelborn mawelborn requested a review from a team as a code owner January 29, 2025 16:38
@mawelborn mawelborn force-pushed the mawelborn/configurable-retry branch 6 times, most recently from f68f18f to 3a7f846 Compare October 16, 2025 21:03
…ait, backoff, and jitter

This makes retry behavior consistent between sync and async clients, and
in its default configuration will get users past network interruptions.
@mawelborn mawelborn force-pushed the mawelborn/configurable-retry branch from 3a7f846 to 1f9ebc1 Compare October 16, 2025 21:18
@mawelborn
Copy link
Contributor Author

Hi @IndicoDataSolutions/pr-be-indicodata-ai folks! I rebased this PR onto main and have all the checks passing. Would appreciate a review when you have a chance. This functionality will be super useful for ProServe and customers.

Copy link
Contributor

@thearchitector thearchitector left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is an urgent thing, this can probably wait, but on the platform side we've been converging on this library, which might be worth considering here instead of shipping our own? it has fancy timing, logging, and backoff stuff we could probably expose if we wanted for better script integrations

self.requests_params: "Optional[AnyDict]" = None
self._disable_cookie_domain: bool = False

self.retry_count: int = int(os.getenv("INDICO_retry_count", "4"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants